package decorator

import "fmt"

// 实现Component抽象类以及ConcreteComponent具体构建
type Component interface {
	Display()
}

type Window struct{}

func (w Window) Display() {
	fmt.Println("显示窗体")
}

type TextBox struct{}

func (t TextBox) Display() {
	fmt.Println("显示文本框")
}

type ListBox struct{}

func (l ListBox) Display() {
	fmt.Println("显示列表框")
}

// 实现ConcreteDecorator具体装饰类
type ScrollBarDecorator struct {
	Component
}

func (sbd ScrollBarDecorator) Display() {
	fmt.Println("为构建增加滚动条")
	sbd.Component.Display()
}

type BlackBorderDecorator struct {
	Component
}

func (bbd BlackBorderDecorator) Display() {
	fmt.Println("为构建增加黑色边框")
	bbd.Component.Display()
}

func NewDecorator(t string, decorator Component) Component {
	switch t {
	case "sbd":
		return ScrollBarDecorator{
			Component: decorator,
		}
	case "bbd":
		return BlackBorderDecorator{
			Component: decorator,
		}
	default:
		return nil
	}
}
